﻿using System;
using System.Threading;
namespace Program14
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("主线程");
            Thread t = new Thread((ThreadProc));
            t.Start();
            t.Abort();//停止线程

            for(var i=0;i<5;i++)
            {
                Console.WriteLine("主线程：做别的事{0}",i);
                Thread.Sleep(0);
            }
            Console.WriteLine("主线程：要等ThreadProc执行完成");
            //阻塞调用线程，指导某个线程执行完成为止
            t.Join();

            for (var i=5;i<10;i++)
            {
                Console.WriteLine("主线程：做别的事{0}", i);
                Thread.Sleep(0);
            }
        }
        public static void ThreadProc()
        {
            for(var i=0;i<10;i++)
            {
                Console.WriteLine("ThreadProc:" + i);
            }
        }
    }
}
